import 'package:enjoy_plus/pages/home/index.dart';
import 'package:enjoy_plus/pages/mine/index.dart';
import 'package:flutter/material.dart';

class TabsPage extends StatefulWidget {
  const TabsPage({Key? key}) : super(key: key);

  @override
  _TabsPageState createState() => _TabsPageState();
}

class _TabsPageState extends State<TabsPage> {
  List tabsList = [
    {
      'label': '首页',
      'icon': 'assets/tabs/home_default.png',
      'activeIcon': 'assets/tabs/home_active.png'
    },
    {
      'label': '我的',
      'icon': 'assets/tabs/my_default.png',
      'activeIcon': 'assets/tabs/my_active.png'
    }
  ];
  int currentIndex = 0;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        // appBar: AppBar(
        //   title: Text('享+社区'),
        //   centerTitle: true,
        // ),
        body: SafeArea(
          child: IndexedStack(
            index: currentIndex,
            children: [HomePage(), MinePage()],
          ),
        ),
        bottomNavigationBar: BottomNavigationBar(
          type: BottomNavigationBarType.fixed,
          selectedItemColor: Color(0xff5592af),
          unselectedItemColor: Color(0xff999999),
          selectedFontSize: 12,
          unselectedFontSize: 12,
          currentIndex: currentIndex,
          items: tabsList
              .map((item) => BottomNavigationBarItem(
                    icon: Image.asset(item['icon'], width: 24, height: 24),
                    activeIcon:
                        Image.asset(item['activeIcon'], width: 24, height: 24),
                    label: item['label'],
                  ))
              .toList(),
          onTap: (index) {
            setState(() {
              currentIndex = index;
            });
          },
        ));
  }
}
